//! 配置测试
//! 
//! 测试配置是否正确加载

use binance_sdk_unified::{
    client::BinanceClientBuilder, ProductType, Environment, Result,
};

#[tokio::main]
async fn main() -> Result<()> {
    // 初始化日志
    tracing_subscriber::fmt()
        .with_max_level(tracing::Level::INFO)
        .init();

    println!("🔧 配置测试");
    println!("==========");

    // 打印环境变量
    println!("📋 环境变量:");
    println!("   BINANCE_HTTP_PROXY: {:?}", std::env::var("BINANCE_HTTP_PROXY"));
    println!("   BINANCE_WS_PROXY: {:?}", std::env::var("BINANCE_WS_PROXY"));

    // 创建客户端
    let client = BinanceClientBuilder::new(
        "test_api_key".to_string(),
        "test_secret_key".to_string(),
        ProductType::Spot,
    )
    .environment(Environment::Demo)
    .timeout(30)
    .retry_count(3)
    .build()?;

    println!("✅ 客户端创建成功");
    println!("   REST URL: {}", client.config().rest_base_url());
    println!("   WebSocket URL: {}", client.config().ws_base_url());
    println!("   HTTP代理: {:?}", client.config().http_proxy);
    println!("   WebSocket代理: {:?}", client.config().ws_proxy);

    // 检查代理配置是否正确加载
    if client.config().http_proxy.is_some() {
        println!("✅ HTTP代理配置已加载: {}", client.config().http_proxy.as_ref().unwrap());
    } else {
        println!("❌ HTTP代理配置未加载");
    }

    if client.config().ws_proxy.is_some() {
        println!("✅ WebSocket代理配置已加载: {}", client.config().ws_proxy.as_ref().unwrap());
    } else {
        println!("❌ WebSocket代理配置未加载");
    }

    Ok(())
}
